package com.gec.it.web;


import com.gec.it.entity.Plans;
import com.gec.it.service.PlansService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wf
 * @since 2022-01-05
 */
@Controller
//@RequestMapping("/plans")
public class PlansController {

    @Autowired
    private PlansService service;

    @GetMapping("/plan_list")
    public String plan_list(Model m){
        List<Plans> plans = service.list2();
        m.addAttribute("list",plans);
        return "plan_list";
    }

    @GetMapping("/plan_add")
    public String plan_add(){
        return "plan_add";
    }

    @PostMapping("/plan_add")
    public String plan_add(Plans p){
        service.save(p);
        return "redirect:plan_list";
    }
}
